import Mock from 'mockjs'

// 生成数据列表
var dataList = []
for (let i = 0; i < Math.floor(Math.random() * 10 + 1); i++) {
  dataList.push(Mock.mock({
    'userId': '@increment',
    'username': '@name',
    'email': '@email',
    'mobile': /^1[0-9]{10}$/,
    'status': 1,
    'roleIdList': null,
    'createUserId': 1,
    'createTime': 'datetime'
  }))
}

// 获取用户列表
export function list () {
  return {
    // isOpen: false,
    url: '/sys/user/list',
    type: 'get',
    data: {
      'msg': 'success',
      'code': 0,
      'page': {
        'totalCount': dataList.length,
        'pageSize': 10,
        'totalPage': 1,
        'currPage': 1,
        'list': dataList
      }
    }
  }
}

// 获取用户信息
export function info () {
  return {
    // isOpen: false,
    url: '/user/info',
    type: 'get',
    data: {
      'msg': 'success',
      'code': 200,
      'roleList': [],
      'menuList': menuList
    }
  }
}

// 修改密码
export function updatePassword () {
  return {
    // isOpen: false,
    url: '/sys/user/password',
    type: 'post',
    data: {
      'msg': 'success',
      'code': 0
    }
  }
}

// 添加用户
export function add () {
  return {
    // isOpen: false,
    url: '/sys/user/save',
    type: 'post',
    data: {
      'msg': 'success',
      'code': 0
    }
  }
}

// 修改用户
export function update () {
  return {
    // isOpen: false,
    url: '/sys/user/update',
    type: 'post',
    data: {
      'msg': 'success',
      'code': 0
    }
  }
}

// 删除用户
export function del () {
  return {
    // isOpen: false,
    url: '/sys/user/delete',
    type: 'post',
    data: {
      'msg': 'success',
      'code': 0
    }
  }
}

// 菜单数据
var menuList = [
  {
    "id": 1,
    "parentId": 0,
    "parentName": null,
    "name": "系统管理",
    "url": "",
    "perms": "",
    "type": 0,
    "icon": "",
    "code": "1",
    "orderNum": 1,
    "open": null,
    "list": [
      {
        "id": 49,
        "parentId": 1,
        "parentName": null,
        "name": "文件管理",
        "url": "manager/sys/file_manager.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-cloud",
        "code": "1_1",
        "orderNum": 0,
        "open": null,
        "list": null
      },
      {
        "id": 2,
        "parentId": 1,
        "parentName": null,
        "name": "用户管理",
        "url": "manager/sys/user.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-user",
        "code": "1_1",
        "orderNum": 2,
        "open": null,
        "list": null
      },
      {
        "id": 3,
        "parentId": 1,
        "parentName": null,
        "name": "角色管理",
        "url": "manager/sys/role.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-users",
        "code": "1_1",
        "orderNum": 3,
        "open": null,
        "list": null
      },
      {
        "id": 4,
        "parentId": 1,
        "parentName": null,
        "name": "菜单管理",
        "url": "manager/sys/menu.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-th-list",
        "code": "1_1",
        "orderNum": 4,
        "open": null,
        "list": null
      },
      {
        "id": 44,
        "parentId": 1,
        "parentName": null,
        "name": "消息管理",
        "url": "manager/msg/sysmsg.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-bell",
        "code": "1_1",
        "orderNum": 6,
        "open": null,
        "list": null
      },
      {
        "id": 394,
        "parentId": 1,
        "parentName": null,
        "name": "开发者管理",
        "url": "manager/devmanager/devinfo.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-file-code-o",
        "code": "1_1",
        "orderNum": 6,
        "open": null,
        "list": null
      },
      {
        "id": 28,
        "parentId": 1,
        "parentName": null,
        "name": "代码生成器",
        "url": "manager/gen/generator.html",
        "perms": "sys:generator:list,sys:generator:code",
        "type": 1,
        "icon": "fa fa-rocket",
        "code": "1_1",
        "orderNum": 7,
        "open": null,
        "list": null
      }
    ]
  },
  {
    "id": 61,
    "parentId": 0,
    "parentName": null,
    "name": "任务调度",
    "url": "",
    "perms": "",
    "type": 0,
    "icon": "",
    "code": "2",
    "orderNum": 0,
    "open": null,
    "list": [
      {
        "id": 6,
        "parentId": 61,
        "parentName": null,
        "name": "任务调度",
        "url": "task/job/schedule.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-tasks",
        "code": "2_61",
        "orderNum": 0,
        "open": null,
        "list": null
      },
      {
        "id": 238,
        "parentId": 61,
        "parentName": null,
        "name": "数据库备份",
        "url": "task/database/database.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-hourglass",
        "code": "2_61",
        "orderNum": 6,
        "open": null,
        "list": null
      }
    ]
  },
  {
    "id": 58,
    "parentId": 0,
    "parentName": null,
    "name": "日志管理",
    "url": "",
    "perms": "",
    "type": 0,
    "icon": "",
    "code": "3",
    "orderNum": 0,
    "open": null,
    "list": [
      {
        "id": 57,
        "parentId": 58,
        "parentName": null,
        "name": "访问日志",
        "url": "manager/log/access_log.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-file-text-o",
        "code": "3_58",
        "orderNum": 0,
        "open": null,
        "list": null
      },
      {
        "id": 29,
        "parentId": 58,
        "parentName": null,
        "name": "系统日志",
        "url": "manager/log/log.html",
        "perms": "sys:log:list",
        "type": 1,
        "icon": "fa fa-file-text-o",
        "code": "3_58",
        "orderNum": 1,
        "open": null,
        "list": null
      },
      {
        "id": 5,
        "parentId": 58,
        "parentName": null,
        "name": "Manager-SQL监控",
        "url": "manager/druid/sql.html",
        "perms": "",
        "type": 1,
        "icon": "fa fa-bug",
        "code": "3_58",
        "orderNum": 5,
        "open": null,
        "list": null
      }
    ]
  }
]